import 'package:flutter/material.dart';
import 'swiper_animate_to_page.dart';
import 'picture_page.dart';
import 'keep_alive_wrapper.dart';

class PageViewPage extends StatefulWidget {
  const PageViewPage({super.key});

  @override
  State<PageViewPage> createState() => _PageViewPageState();
}

class _PageViewPageState extends State<PageViewPage> {
  List<Widget> pageList = [];

  @override
  void initState() {
    super.initState();
    List listData = [
      {
        "imageUrl": 'images/a.jpg',
      },
      {
        "imageUrl": 'images/b.jpg',
      },
      {
        "imageUrl": 'images/c.jpg',
      },
      {
        "imageUrl": 'images/d.jpg',
      }
    ];
    for (int i = 0; i < listData.length; ++i) {
      pageList.add(KeepAliveWrapper(
        child: PicturePage(
          url: listData[i]["imageUrl"],
        ),
      ));
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("pageview演示"),
      ),
      body: ListView(
        children: [Swiper(pageList: pageList)],
      ),
    );
  }
}
